#include "mainwindow.h"
#include "ui_mainwindow.h"

MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    QMenuBar*menuBar = new QMenuBar();
    this->setMenuBar(menuBar);//创建菜单

    QMenu* menu = new QMenu("菜单");
    menuBar->addMenu(menu);

    QAction*action1 = new QAction("菜单项1");
    QAction*action2 = new QAction("菜单项1");
    menu->addAction(action1);
    menu->addSeparator();//分割线
    menu->addAction(action2);

    QMenu *menu1= new QMenu("子菜单");
    menu->addMenu(menu1);
    menu1->addAction(action1);


}

MainWindow::~MainWindow()
{
    delete ui;
}

